package com.ruoyi.pidaijiData.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.pidaijiData.domain.pad.PidaijiTaskReqDTO;
import com.ruoyi.pidaijiData.domain.report.PidaijiReportData;
import com.ruoyi.pidaijiData.service.impl.IDataPidaijiService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.concurrent.ExecutionException;

/**
 * 皮带机-测试Controller
 * 
 * @author lgq
 * @date 2023-1-2
 */
@RestController
@RequestMapping("/pidaijiData/all")
@Api(value="皮带机-测试",tags = "皮带机-测试接口")
public class DataPidaijiController extends BaseController
{

    @Autowired
    public IDataPidaijiService dataPidaijiService;


    /**
     * 查询此皮带机任务的所有测试项目数据
     */
    @PreAuthorize("@ss.hasPermi('pidaijiData:task:query')")
    @GetMapping("/{dataTaskId}")
    @ApiOperation(value="查询此皮带机任务的所有测试项目数据")
    @ApiImplicitParam(paramType="query", name = "dataTaskId", value = "任务id", required = true, dataType = "Long")
    public AjaxResult getDetailPidaiji(@PathVariable("dataTaskId") Long dataTaskId) throws InterruptedException, ExecutionException {
        PidaijiTaskReqDTO pidaijiTaskReqDTO = dataPidaijiService.getDetailPidaiji(dataTaskId);
        return AjaxResult.success(pidaijiTaskReqDTO);
    }


    /**
     * 根据任务id删除整条皮带机测试结果
     */
    @PreAuthorize("@ss.hasPermi('pidaijiData:task:remove')")
    @Log(title = "根据任务id删除整条皮带机测试结果", businessType = BusinessType.DELETE)
    @DeleteMapping("/updateDataPidaijiByDataTaskId/{dataTaskId}")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query", name = "dataTaskId", value = "任务id", required = true, dataType = "Long"),
    })
    @ApiOperation(value="根据任务id删除整条皮带机测试结果")
    public AjaxResult updateDataPidaijiByDataTaskId(@PathVariable("dataTaskId")Long dataTaskId)
    {
        return toAjax(dataPidaijiService.delAllPidaijiData(dataTaskId));
    }

    /**
     * 保存的皮带机数据导入报告
     */
    @PreAuthorize("@ss.hasPermi('pidaijiData:import:query')")
    @PostMapping("/dataPidaijiImportReport")
    @ApiOperation(value="保存的皮带机数据导入报告")
    public AjaxResult dataPidaijiImportReport(@ApiParam(name="测试项目结果数据",value="传入json格式",required=true)@RequestBody PidaijiReportData pidaijiReportReqDTO){
        return AjaxResult.success(dataPidaijiService.dataPidaijiImportReport(pidaijiReportReqDTO));
    }

}
